package com.qumitech.visualnovel.controller.rest.novel;

import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletRequest;
import com.qumitech.visualnovel.model.common.BaseResponse;
import com.qumitech.visualnovel.service.novel.EngineService;

@RestController
@Api(value = "引擎模块", description = "引擎模块")
public class EngineRest {
    @Autowired
    private EngineService engineService;

    @ApiOperation(value = "获取引擎最新版本号", notes = "获取引擎最新版本号")
    @GetMapping("/api/engine/version")
    public BaseResponse getNewVersion() {
        return engineService.getNewVersion();
    }


    @ApiOperation(value = "上传引擎更新", notes = "上传引擎更新")
    @ApiImplicitParams({
        @ApiImplicitParam(name="mainVersion", value="主版本", required=true),
        @ApiImplicitParam(name="subVersion", value="子版本", required=true),
        @ApiImplicitParam(name="file", value="更新文件", required=true)
    })
    @PostMapping("/api/engine/upload")
    public BaseResponse upload(HttpServletRequest request) {
        return engineService.upload(request);
    }
}
